package cn.wenhaha.app.mapping.bean.validator;

import cn.hutool.cron.pattern.CronPattern;
import lombok.extern.slf4j.Slf4j;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;

/**
 * 验证实现类
 * --------
 *
 * @author ：wyndem
 * @Date ：Created in 2022-10-07 12:58
 */
@Slf4j
public class CronValidator implements ConstraintValidator<Cron, String> {




    @Override
    public boolean isValid(String o, ConstraintValidatorContext context) {
        try {
            new CronPattern(o);
        } catch (Exception e) {
            log.error(e.getMessage());
            return false;
        }
        return true;
    }
}
